﻿/// <summary>
/// View model for visit pictures.
/// </summary>
function PictureViewModel() {
    var v =
    {
        /// <summary>
        /// Id of the picture.
        /// </summary>
        PictureID: ko.observable()

        /// <summary>
        /// Title for the picture.
        /// </summary>
        , Title: ko.observable()
        /// <summary>
        /// Url for the picture.
        /// </summary>
        , Url: ko.observable()
        /// <summary>
        /// Id for the DOM element.
        /// </summary>
        , Id: ko.observable()
        /// <summary>
        /// Boolean indicating whether the current picture is selected.
        /// </summary>   
        , IsSelected: ko.observable()
        /// <summary>
        /// Number of the picture in the list picture. It is used to set the page number.
        /// </summary>
        , Number: ko.observable()

        /// <summary>
        /// Constructor of the class
        /// </summary>
        , load: function (pictureId, url, title) {
            this.IsSelected(false);
            this.PictureID(pictureId);
            this.Title(title);
            this.Url(url);

            this.Id("picture" + pictureId);
        }

        /// <summary>
        /// Method to call to display this picture.
        /// </summary>
        , select: function () {
            viewModel.selectPicture(this);
        }

        /// <summary>
        /// Display the picture.
        /// </summary>
        , show: function () {
            $('#' + this.Id()).fadeTo(1000, 1);
            this.IsSelected(true);
        }

        /// <summary>
        /// Hide the picture.
        /// </summary>
        , hide: function () {
            $('#' + this.Id()).fadeTo(1000, 0);
            this.IsSelected(false);
        }
    };

    return v;
}